/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.boatskeeper.server.handler.boat;

import net.customware.gwt.dispatch.server.ActionHandler;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;
import org.lucava.boatskeeper.server.MockBoatDao;
import org.lucava.boatskeeper.shared.rpc.boat.AddBoat;
import org.lucava.boatskeeper.shared.rpc.boat.AddBoatResult;

/**
 *
 * @author glenn
 */
public class AddBoatHandler implements ActionHandler<AddBoat, AddBoatResult> {

    @Override
    public Class<AddBoat> getActionType() {
        return AddBoat.class;
    }

    @Override
    public AddBoatResult execute(AddBoat a, ExecutionContext ec) throws ActionException {

        MockBoatDao.add(a.getBoat());

        AddBoatResult addBoatResult = new AddBoatResult(a.getBoat());
        return addBoatResult;
    }

    @Override
    public void rollback(AddBoat a, AddBoatResult r, ExecutionContext ec) throws ActionException {
    }
}
